home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xml / Comment.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  3.0 KB  |  115 lines

  1. package com.extensibility.xml;
  2.  
  3. import com.extensibility.util.Debug;
  4. import com.extensibility.util.StringUtilities;
  5. import java.util.Vector;
  6.  
  7. public class Comment implements Cloneable {
  8.    protected static final char KIND_START = '#';
  9.    protected static final char KIND_END = ':';
  10.    public static final String USAGE = "USAGE";
  11.    public static final String AUTHOR_OBSOLETE = "AUTHOR";
  12.    public static final String CHANGES = "CHANGES";
  13.    public static final String INTRO = "INTRO";
  14.    public static final String UNKIND = "";
  15.    public static final String ALL = null;
  16.    private static Vector KIND_ORDER = new Vector();
  17.    String comment;
  18.    String kind;
  19.  
  20.    public Comment(String var1) {
  21.       KIND_ORDER.addElement("");
  22.       KIND_ORDER.addElement("USAGE");
  23.       KIND_ORDER.addElement("CHANGES");
  24.       KIND_ORDER.addElement("INTRO");
  25.       this.comment = var1;
  26.       if (var1.length() > 0 && var1.charAt(0) == '#') {
  27.          int var2 = var1.indexOf(58);
  28.          if (var2 > 0) {
  29.             this.kind = var1.substring(1, var2);
  30.             this.comment = var1.substring(var2 + 1, var1.length());
  31.             this.removeObsoleteKind();
  32.          }
  33.       }
  34.  
  35.    }
  36.  
  37.    public Comment(String var1, String var2) {
  38.       KIND_ORDER.addElement("");
  39.       KIND_ORDER.addElement("USAGE");
  40.       KIND_ORDER.addElement("CHANGES");
  41.       KIND_ORDER.addElement("INTRO");
  42.       this.kind = var1;
  43.       this.comment = var2;
  44.       this.removeObsoleteKind();
  45.    }
  46.  
  47.    private void removeObsoleteKind() {
  48.       if (this.kind != null) {
  49.          if (this.kind.equals("AUTHOR") || this.kind.length() == 0) {
  50.             this.kind = null;
  51.          }
  52.  
  53.       }
  54.    }
  55.  
  56.    public Object clone() {
  57.       Comment var1 = null;
  58.  
  59.       try {
  60.          var1 = (Comment)super.clone();
  61.       } catch (CloneNotSupportedException var3) {
  62.          Debug.assert(false, "Problem cloning Comment.");
  63.       }
  64.  
  65.       return var1;
  66.    }
  67.  
  68.    public int compareKindTo(Comment var1) {
  69.       return this.getKindIndex() - var1.getKindIndex();
  70.    }
  71.  
  72.    public void setComment(String var1) {
  73.       this.comment = var1;
  74.    }
  75.  
  76.    public String getComment() {
  77.       return this.comment;
  78.    }
  79.  
  80.    public String getComment(boolean var1) {
  81.       if (!var1) {
  82.          return this.getComment();
  83.       } else {
  84.          String var2 = this.comment;
  85.          var2 = StringUtilities.replace(var2, "&", "&");
  86.          var2 = StringUtilities.replace(var2, "<", "<");
  87.          var2 = StringUtilities.replace(var2, ">", ">");
  88.          return var2;
  89.       }
  90.    }
  91.  
  92.    public String toString() {
  93.       return this.comment;
  94.    }
  95.  
  96.    public String getSource() {
  97.       return this.kind != null ? String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("<!--#").concat(String.valueOf(this.kind))).concat(String.valueOf(':'))).concat(String.valueOf(StringUtilities.replace(this.comment, "--", "- -")))).concat(String.valueOf("-->"))).concat(String.valueOf(BaseDeclaration.LINE_SEPARATOR)) : String.valueOf(String.valueOf(String.valueOf("<!--").concat(String.valueOf(StringUtilities.replace(this.comment, "--", "- -")))).concat(String.valueOf("-->"))).concat(String.valueOf(BaseDeclaration.LINE_SEPARATOR));
  98.    }
  99.  
  100.    private int getKindIndex() {
  101.       int var1;
  102.       for(var1 = 0; var1 < KIND_ORDER.size(); ++var1) {
  103.          if (((String)KIND_ORDER.elementAt(var1)).equals(this.getKind())) {
  104.             return var1;
  105.          }
  106.       }
  107.  
  108.       return var1;
  109.    }
  110.  
  111.    public String getKind() {
  112.       return this.kind == null ? "" : this.kind;
  113.    }
  114. }
  115.